package com.example.mapstructtest.controller;

import com.example.mapstructtest.converter.UserModelConverter;
import com.example.mapstructtest.model.UserAddress;
import com.example.mapstructtest.model.UserModel;
import com.example.mapstructtest.vo.UserVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author dangwen1
 * @date 2021年12月03日 11:23
 * @description
 */
@RestController
public class UserController {
    public static void main(String[] args) {
        UserModel userModel = new UserModel();
        UserAddress userAddress = new UserAddress();
        userAddress.setProvinceId(1);
        userAddress.setCityId(1);
        userAddress.setProvinceName("河南省");
        userAddress.setCityName("郑州市");
        List<UserAddress> list = new ArrayList<>();
        list.add(userAddress);
        userModel.setAddresses(list);
        userModel.setUsername("党文");
        userModel.setAge(18);
        userModel.setBirthday(new Date());

        UserVO userVO = UserModelConverter.INSTANCE.sourceToTarget(userModel);
        System.out.println(userVO);
    }
    @GetMapping("userTest")
    public String test(){
        return "user test success";
    }
}
